home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / system / Narrator.st < prev    next >
Encoding:
Text File  |  2004-01-31  |  4.6 KB  |  189 lines

  1. " ----------------------------------------------------------------------"
  2. " Narrator Class is derived from abstract Device Class.                 "
  3.  
  4. "  WARNING:  You should know what you're doing to the Amiga OS before   "
  5. "            messing with this Class, or any other System Class!        " 
  6.  
  7. " This class is a Singleton Class, meaning there can be only one 
  8.   narrator per AmigaTalk program (what would more than one narrator
  9.   talking at the same time sound like, anyway?)
  10. "
  11. " ----------------------------------------------------------------------"
  12.  
  13. Class Narrator :Device ! uniqueInstance !
  14. [
  15.   isSingleton
  16.  
  17.       ^ true
  18. |
  19.   close
  20.  
  21.       <primitive 230 0 self>.
  22.       
  23.       <primitive 250 5 0 self>.
  24.       
  25.       ^ nil
  26. |
  27.   privateOpen
  28.  
  29.       "Use new method instead."
  30.  
  31.       ^ <primitive 230 1>
  32. |
  33.   setVolume: newSpeakingVolume
  34.  
  35.       "Range:  0 to 64 (max)"
  36.  
  37.       ^ <primitive 230 2 newSpeakingVolume>
  38.   setSex: newSpeakerSex
  39.  
  40.       "Female = 0, & Male = 1"
  41.  
  42.       ^ <primitive 230 3 newSpeakerSex>
  43.   setPitch: newSpeakingPitch
  44.  
  45.       "Range:  65 to 320Hz"
  46.       ^ <primitive 230 4 newSpeakingPitch>
  47. |
  48.   setMode: newModeString
  49.  
  50.       "valid string settings are: robotic, natural & manual"
  51.       ^ <primitive 230 5 newModeString>
  52. |
  53.   setRate: newSpeakingRate
  54.  
  55.       "Range: 40 to 400 words/minute"
  56.       ^ <primitive 230 6 newSpeakingRate>
  57. |
  58.   setFormant1: percentDeviation 
  59.  
  60.       "Range: -100 to 100 in steps of 5, Default = 0"
  61.       ^ <primitive 230 7 1 percentDeviation>
  62. |
  63.   setFormant2: percentDeviation 
  64.  
  65.       "Range: -100 to 100 in steps of 5, Default = 0"
  66.       ^ <primitive 230 7 2 percentDeviation>
  67. |
  68.   setFormant3: percentDeviation 
  69.  
  70.       "Range: -100 to 100 in steps of 5, Default = 0"
  71.       ^ <primitive 230 7 3 percentDeviation>
  72.   setFormant1Amplitude: newAmplitude
  73.  
  74.       "RANGE: 31 to -32 dB."
  75.       ^ <primitive 230 8 1 newAmplitude>
  76.   setFormant2Amplitude: newAmplitude
  77.  
  78.       "RANGE: 31 to -32 dB."
  79.       ^ <primitive 230 8 2 newAmplitude>
  80.   setFormant3Amplitude: newAmplitude
  81.  
  82.       "RANGE: 31 to -32 dB."
  83.       ^ <primitive 230 8 3 newAmplitude>
  84. |
  85.   setEnthusiasm: aFloat
  86.  
  87.       "From 1/32 to 32/32 only (32/32 = default)"
  88.       ^ <primitive 230 9 aFloat>
  89. |
  90.   setPriority: newSpeakingPriority
  91.  
  92.       "Range: -128 to 127, Default = 100"
  93.       ^ <primitive 230 10 newSpeakingPriority>
  94.   setPitchModulation: voiceQuiver
  95.  
  96.       "Range: 0 to 255"
  97.       ^ <primitive 230 11 voiceQuiver>
  98.   setArticulation: newPercentArticulation
  99.  
  100.       "Set amount of slurring of words.  Range:  0 to 255% (max)"
  101.       ^ <primitive 230 12 newPercentArticulation>
  102.   setPhoneme: phonemeString
  103.  
  104.       "Used with setCentralizeValue: to change the accent of Narrator."
  105.  
  106.       "Valid strings are:"
  107.       
  108.       "IY  long  e as in beet,   eat.
  109.        IH  short i as in bit,    in.
  110.        EH  short e as in bet,    end.
  111.        AE  short a as in bat,    ad.
  112.        AA  short o as in bottle, on.
  113.        AH  short u as in but,    up.
  114.        AO  short a as in ball,   awl.
  115.        OW  long  o as in boat,   own.     (diphthong)
  116.        UH  short u as in book,   soot.
  117.        ER  short i as in bird,   early.
  118.        UW  long  u as in brew,   boolean. (diphthong)"
  119.  
  120.       "No checking is performed on your string, so get it right!" 
  121.  
  122.       ^ <primitive 230 13 phonemeString>
  123.   setCentralizeValue: newCentralizePercent
  124.  
  125.       "Used with setPhoneme: to change the accent of Narrator."
  126.       "Range: 0 to 100%"
  127.       ^ <primitive 230 14 newCentralizePercent>
  128.   setFlags: newFlags 
  129.  
  130.       "NDF_NEWIORB = 1, NDF_WORDSYNC = 2, NDF_SYLSYNC = 4"
  131.       ^ <primitive 230 15 newFlags>
  132.   setVoicingAmplitude: newAVBias  
  133.  
  134.       "RANGE: 31 to -32 dB."
  135.       ^ <primitive 230 16 newAVBias>
  136.   setFricationAmplitude: newAFBias 
  137.  
  138.       "RANGE: 31 to -32 dB."
  139.       ^ <primitive 230 17 newAFBias>
  140.   speak: normalString
  141.  
  142.       ^ <primitive 230 18 normalString>
  143.   speakPhonetics: phoneticString
  144.       ^ <primitive 230 19 phoneticString>
  145.   translateText: aString
  146.  
  147.       "Returns a Phonetic string representation of aString"
  148.       ^ <primitive 230 20 aString>
  149. |
  150.   new: aValue
  151.  
  152.       'Cannot use new: method on Narrator class!' print.
  153.       ^ nil
  154. |
  155.   privateSetup ! check !
  156.  
  157.       (uniqueInstance isNil)
  158.          ifTrue: [ check <- (self privateOpen).
  159.  
  160.                    (check = 0)
  161.                       ifTrue:  [ uniqueInstance <- 'MyNarrator'.
  162.                                  ^ self
  163.                                ]
  164.                       ifFalse: [ 'Problem opening Narrator:' print.
  165.                                  <primitive 230 21 check> print.
  166.                                  ^ uniqueInstance <- nil
  167.                                ] 
  168.                  ]
  169. |
  170.   new 
  171.  
  172.       ^ (self privateSetup)
  173. ]
  174.